package com.lipaluma.test.db.annotations.dataSource;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.lipaluma.test.db.internal.DialectEnum;

/**
 * Annotation that declares a DataSource that the framework will create.
 * @author Mario
 */
@Documented
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface DataSource {
	/**
	 * the name of the DataSource
	 * @return
	 */
	String name() default "";
	/**
	 * driver of the DataSource
	 * @return
	 */
	String driver();
	/**
	 * url of the DataSource
	 * @return
	 */
	String url();
	/**
	 * username (login) of the DataSource. Optional if anonymous is true.
	 * @return
	 */
	String user() default "";
	/**
	 * password of the DataSource. Optional if anonymous is true.
	 * @return
	 */
	String password() default "";
	/**
	 * Dialect of the dataSource. Mysql is the Default.
	 * @return
	 */
	DialectEnum dialect() default DialectEnum.MYSQL;
	/**
	 * Used to connect to database without login and password.
	 * By Default, the field is set to false that indicates that the username and the password are required.<br/>
	 * @return
	 */
	boolean anonymous() default false;

	/**
	 * With {@link List}, several DataSource can be defined
	 * @author Mario
	 */
	@Documented
	@Inherited
	@Target(ElementType.TYPE)
	@Retention(RetentionPolicy.RUNTIME)
	public @interface List {
		DataSource[] value();
	}
}
